<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Developers</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->



<!-- InstanceEndEditable -->
</head>

<body>
<table border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100"><p>&nbsp;</p>
      <table border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
      <tr>
        <td><table border="0" cellpadding="1" cellspacing="2" bgcolor="#FFFFFF">
            <tr>
              <td><a href="index.html">Overview</a></td>
            </tr>
            <tr>
              <td><a href="userguide.html">User Guide</a> </td>
            </tr>
            <tr>
              <td><a href="codesamples.html">Code Samples</a> </td>
            </tr>
            <tr>
              <td><a href="developers.html">Developers</a></td>
            </tr>
            <tr>
              <td><a href="requirements.html">Requirements</a></td>
            </tr>
            <tr>
              <td><a href="limitations.html">Limitations</a> </td>
            </tr>
        </table></td>
      </tr>
    </table></td>
    <td width="75">&nbsp;</td>
    <td><!-- InstanceBeginEditable name="main" -->
      <h1>Developers</h1>
      <p>gekmllib was originally generated using a hacked together tool which did a rough parse of the KML Schema, and output the relevant classes. I then made some changes for convenience, for instance, changed the implementation of coordinates in Point, LineString and LinearRing from String to double. The tool which I used to generate this will not be distributed. If it becomes required for some reason, I'll rewrite it. It was written as a quick and dirty method of getting this library up and running, and it certainly is dirty, too dirty to be seen in public.</p>
      <p>I tried using Castor and XMLBeans to generate such a library, but I was not happy with the code they generated. For one, using them required a lot of typechecking and casting, which was an inconvenience and resulted in ugly code. For another, I wanted to be able to easily modify the objects they generated to store information that would let me generate KML Updates, which would only contain information about the most recent modifications to objects. I tried to do this to XMLBean's generated library, but quickly realised it would be easier for me to write my own generator, and get that to produce the modifications I wanted also. </p>
      <p><strong>Architecture </strong><br />
      There's an object in gekmllib for each complex type in the KML schema. All objects repesenting KML Objects in gekmllib derive from Node. Node contains flags which signal whether a Node has been modified, or <em>is dirty</em>, and has lists of any newly created and deleted children associated with the Node. Each subclass of Node can have its own simple properties and other child Nodes. All Nodes, except the root Kml node have a parent. When a Node is modified, it is marked as <em>dirty</em>, and it's parent is informed. So, we can check whether a document has undergone any modifications by just checking whether the root is dirty. </p>
      <p>When toKML is called, the whole document tree is traversed, and each object is asked to produce a representation of itself using its toKML(). </p>
      <p>When toUpdateKML is called only those parts of the document tree marked dirty are traversed, and then only those parts of a Node which have changed are added to the KML Update. The KML for any nodes which have been newly created, or deleted are printed out first, and these nodes are marked as not dirty, since it does not make sense to produce updates for deleted or newly created nodes.</p>
      <p>Once toUpdateKML is finished, the entire KML document is marked as not dirty.</p>
    <!-- InstanceEndEditable --></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
